$("#table").bootstrapTable({
    url: '/room/getAppendRoom',
    contentType: 'application/x-www-form-urlencoded',
    method: 'POST',
    toolbar: '#toolbar',
    sidePagination: 'server',
    pageNumber: 1,//当前页
    pageSize: 15,//每页条数
    pageList: [15, 50, 100, 'ALL'],
    dataType: 'json',//返回数据的类型
    /*detailView: true,*/
    cache: false,
    pagination: false,//使用分页
    /*showRefresh: true,//右上角刷新按钮
    showColumns: true,//右上角,列,列表*/
    // queryParams:function (params) {
    //     params["parentId"] = $("#parent-select").val();
    //     return params;
    // },
    classes: 'table table-hover table-striped',
    columns: [{
        checkbox: true
    }, {
        field: 'number',
        title: '序号',
        align: 'center',
        formatter: function (value, row, index) {
            return (index + 1);
        },
    }, {
        field: "id",
        title: "编号",
        align: "center"
    }, {
        field: "order.id",
        title: "房间订单编号",
        align: "center"
    },{
        field: "date",
        title: "续费时间",
        align: "center"
    }, {
        field: "operator",
        title: "操作",
        align: "center",
        formatter: function (value, row, index) {
            var str = "<span class='glyphicon glyphicon-pencil' onclick='updateAppendRoomSubmit(" + row.id + ")'></span>&nbsp&nbsp;" +
                "<span class='glyphicon glyphicon-trash' onclick='delPrivilegeById(" + row.id + ")'></span>&nbsp&nbsp;";

            return str;
        }
    }]
});


/**
 * 添加退房信息
 */
function AddAppendRoom() {
    $("#addappendroomModal").modal("show");
    $("#addappendroomModal .modal-body").load("/room/openAppendRoomAdd");
}

/**
 * 添加退房信息提交
 */
function addAppendRoomSubmit() {
    $.post("/room/AddAppendRoom",
        {
            "roomorderid": $("#roomorderid").val(),
            "appenddate": $("#appenddate").val()
        }, function (data) {
            if (data.result>0) {
                $("#table").bootstrapTable('refresh');
                swal('添加成功!', '信息添加成功!', 'success');
                $("#addappendroomModal").modal('hide');
            } else {
                swal('添加失败!', '信息添加失败!', 'error');
                $("#addappendroomModal").modal('hide');
            }
        }, "json"
    );
}
/**
 * 打开修改房间订单的模态框并显示默认数据
 * @param id 默认显示的房间订单编号
 * */
function updateAppendRoomSubmit() {
    var url = "/room/openappendroomdel";
    $("#changeAppendRoomModal").modal('show');
    $("#changeAppendRoomModal .modal-body").load(url);
}

/**
 * 修改权限表单提交
 */
function changeAppendRoomSubmit() {
    $.post("/room/updateAppendRoom",
        {
            "roomorderid": $("#roomorderid").val(),
            "appenddate": $("#appenddate").val()
        }, function (data) {
            if (data.updates) {
                $("#table").bootstrapTable('refresh');
                swal('修改成功!', '房间订单修改成功,请重新登录!', 'success');
                $("#changeAppendRoomModal").modal('hide');
            } else {
                swal('修改失败!', '房间订单修改失败,请重试!', 'error');
                $("#changeAppendRoomModal").modal('hide');
            }
        }, "json");
}